Skip to content

Conversation

@ps06756
Copy link

@ps06756 ps06756 commented Dec 29, 2025

Summary

  • Updated the import in client.py to use the new streamable_http_client function name instead of the deprecated streamablehttp_client
  • Added backward-compatible import that first tries the new function name, then falls back to the old one for older MCP SDK versions
  • Updated unit tests to mock the new function name

Details

The MCP Python SDK v1.24.0 (released Dec 12, 2025) introduced a new streamable_http_client function and deprecated the old streamablehttp_client (see PR #1177).

Users running with MCP SDK >= 1.24.0 see the following warning:

DeprecationWarning: Use streamable_http_client instead

This fix uses a try/except import pattern to:

  1. Use the new streamable_http_client when available (MCP >= 1.24.0)
  2. Fall back to streamablehttp_client for older versions (MCP < 1.24.0)

Test plan

  • All existing unit tests pass (uv run pytest tests/unit/test_client.py -v)
  • Verified backward compatibility with MCP 1.20.0
  • Verified the new function exists in MCP 1.25.0 on PyPI

Fixes #128

Update the import in client.py to use the new `streamable_http_client`
function name instead of the deprecated `streamablehttp_client`.

Added backward-compatible import that:
- First tries to import the new `streamable_http_client` function
- Falls back to the old `streamablehttp_client` for older MCP SDK versions

This fixes the DeprecationWarning introduced in MCP SDK v1.24.0:
"Use streamable_http_client instead of streamablehttp_client"

Fixes aws#128
@ps06756 ps06756 requested a review from a team as a code owner December 29, 2025 00:50
@ps06756 ps06756 requested review from bidesh and harv-aws December 29, 2025 00:50
@ps06756
Copy link
Author

ps06756 commented Jan 8, 2026

@bidesh / @harv-aws Bumping this up, for review

Copy link

@bidesh bidesh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ps06756 Thanks for the change!

I added a comment regarding the compatibility of the two methods. I think the tests might pass either because you were still getting streamablehttp_client imported (because the mcp included is still old) or we have gaps in our tests.

Tests we will look after, but if you could verify that the change works are expected without regression, then happy to approve and merge. Thanks for the change!


# Return the streamable HTTP client context manager with AWS IAM authentication
return streamablehttp_client(
return streamable_http_client(
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My understanding from this change modelcontextprotocol/python-sdk#1177 is that the signature has changed on how the client is passed.

If streamable_http_client is imported instead of streamablehttp_client, I think this will break because the new implementation will use a default http_client which will not have the headers, auth etc here set up.

Copy link
Author

@ps06756 ps06756 Jan 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, good catch! I had wrongly assumed that we would be using the version > 1.24.0 always,

In this case, how do you suggest we determine whether we are on a new version or old version ?

One option is we can use the packaging dependency and do something like

from importlib.metadata import version
  from packaging.version import Version

  # Check version at import time
  _MCP_VERSION = Version(version('mcp'))
  _NEW_API_AVAILABLE = _MCP_VERSION >= Version('1.24.0')

  if _NEW_API_AVAILABLE:
      from mcp.client.streamable_http import streamable_http_client as _streamable_http_client_new
  else:
      from mcp.client.streamable_http import streamablehttp_client as _streamablehttp_client_old

Or we can directly check the method signature at runtime and determine that ?

import inspect

  _NEW_API_AVAILABLE = False
  _streamable_http_client_new = None
  _streamablehttp_client_old = None

  try:
      from mcp.client.streamable_http import streamable_http_client as _candidate

      sig = inspect.signature(_candidate)
      # New API has 'http_client' param, old API has 'auth' param
      if 'http_client' in sig.parameters and 'auth' not in sig.parameters:
          _NEW_API_AVAILABLE = True
          _streamable_http_client_new = _candidate
  except (ImportError, ValueError):
      pass

  if not _NEW_API_AVAILABLE:
      try:
          from mcp.client.streamable_http import streamablehttp_client as _streamablehttp_client_old
      except ImportError:
          from mcp.client.streamable_http import streamable_http_client as _streamablehttp_client_old

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, the only way we get rid of the DeprecationWarning is if we update the version. I talked to @wzxxing on any problems with upgrading. Copying his reply here:

The fastmcp v2.14.1 introduced some incompatible change that changes the signature of the the httpx client factory.
The fix should be just to add kw args to this function.


3:28

@ps06756 would you be willing to include this change and upgrade the dependency?

If not, then please comment in the linked issue and we will prioritise the fix and update.

@wzxxing
Copy link
Contributor

wzxxing commented Jan 12, 2026

We should upgrade the fastmcp version instead:

v2.14.1 requires the **kw args to be added to

def client_factory(
headers: Optional[Dict[str, str]] = None,
timeout: Optional[httpx.Timeout] = None,
auth: Optional[httpx.Auth] = None,
) -> httpx.AsyncClient:
return create_sigv4_client(
service=service,
session=session,
region=region,
headers=headers,
timeout=custom_timeout,
metadata=metadata,
auth=auth,
)

because the factory will be called with more than just headers, timeout, auth.

tonyxwz/fastmcp@076ec0c

Instead, it will be called with

        httpx_client_kwargs: dict[str, Any] = {
            "headers": headers,
            "auth": self.auth,
            "follow_redirects": True,
        }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DeprecationWarning: Use streamable_http_client instead of streamablehttp_client

3 participants